package com.fnzn.entranceGuard.service.power.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.fnzn.entranceGuard.entity.power.PowerHour;
import com.fnzn.entranceGuard.mapper.power.PowerHourMapper;
import com.fnzn.entranceGuard.service.power.IPowerHourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sxf
 * @since 2019-01-03
 */
@Service
public class PowerHourServiceImpl extends ServiceImpl<PowerHourMapper, PowerHour> implements IPowerHourService {
    @Autowired
    private PowerHourMapper hourMapper;

    @Override
    public PowerHour getByDateHour(String deviceId ,String date, Integer hour,String powerId) {
        Wrapper wrapper = new EntityWrapper();
        wrapper.eq("device_id",deviceId);
        wrapper.eq("date",date);
        wrapper.eq("hour",hour);
        wrapper.eq("power_id",powerId);
        List<PowerHour> list = hourMapper.selectList(wrapper);
        if(list!=null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
